//
// Created by xili on 2024/9/4 21:14.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    long long maxKelements(vector<int> &nums, int k) {
        long long ans = 0;
        priority_queue<int> pq(nums.begin(), nums.end());
        while (k--) {
            int cur = pq.top();
            ans += cur;
            pq.push((cur + 2) / 3);
            pq.pop();
        }
        return ans;
    }
};